package com.xsmart.common.entity;

import com.baomidou.mybatisplus.plugins.Page;

import java.util.List;

public class EcomPage<T> {
    private List<T> list;
    private Pagination pagination;

    public EcomPage(Page page) {
        pagination = new Pagination();
        pagination.setTotal(page.getTotal());
        pagination.setPageSize(page.getSize());
        pagination.setCurrent(page.getCurrent());
        setList(page.getRecords());
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public Pagination getPagination() {
        return pagination;
    }

    public void setPagination(long total, int pageSize, int current) {
        Pagination pagination = new Pagination();
        pagination.setTotal(total);
        pagination.setPageSize(pageSize);
        pagination.setCurrent(current);
        this.setPagination(pagination);
    }

    public void setPagination(Pagination pagination) {
        this.pagination = pagination;
    }
}
